package com.macro.mall.portal.controller;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.common.dto.EsTableRes;
import com.macro.mall.common.dto.SearchFields;
import com.macro.mall.portal.remton.EsServiceRemton;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import javax.annotation.Resource;
import java.util.Map;

@Resource
public class SearchController {
    @Resource
    private EsServiceRemton esServiceRemton;
    @PostMapping("/search")
    public CommonResult<Map<String,Object>> search(@PathVariable String text){
        EsTableRes esTableRes = new EsTableRes();
        SearchFields searchFields = new SearchFields();
        searchFields.setProductName("name");
        esTableRes.setKeyWord(text);
        esTableRes.setIndexName("logs");
        esTableRes.setSearchFields(searchFields);
        CommonResult<Map<String, Object>> search = esServiceRemton.search(esTableRes);
        return CommonResult.success(search.getData());
    }
}
